﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkShopMasterForm.aspx.cs" Inherits="FX.CC.Andon.WebSite.BasicDataManage.WorkShopMasterForm" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>车间管理</title>
<script src="../lib/boot.js" type="text/javascript"></script>
</head>
<body>
    <div class="mini-toolbar" style="padding: 2px; border-bottom: 0;">
        <table style="width: 100%;">
            <tr>
                <td style="width: 100%;">
                    <a class="mini-button" iconcls="icon-add" onclick="add();" plain="true">添加</a> <a
                        class="mini-button" iconcls="icon-edit" onclick="edit()" plain="true">编辑</a>
                    <span class="separator"></span><a class="mini-button" iconcls="icon-freeze" onclick="freeze()"
                        plain="true">禁用</a> <a class="mini-button" iconcls="icon-unfrozen" onclick="unfrozen()"
                            plain="true">启用</a> <span class="separator"></span><a class="mini-button" onclick="close()"
                                iconcls="icon-close" plain="true">关闭</a>
                </td>
            </tr>
        </table>
    </div>
    <!--撑满页面-->
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width: 100%; height: 100%;" idfield="WSID"
            sizelist="[10,20,50,100]" pagesize="20" onrowdblclick="ondoubleclick()">
            <div property="columns">
                <div type="indexcolumn" width="15">
                </div>
                <div field="RecStatus" width="70" headeralign="center" allowsort="true" renderer="onRecStatusRenderer">
                    状态
                </div>
                <div field="WSCode" width="120" headeralign="center" allowsort="true">
                    车间编号</div>
                <div field="WSName" width="120" headeralign="center" allowsort="true">
                    车间名称</div>
                <div field="WSDesc" width="300" headeralign="center" allowsort="false">
                    描述
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setUrl("../service/BasicDataManageHandler.ashx?action=GetWorkShopList");
        grid.load();
        function add() {
            mini.open({
                url: "BasicDataManage/WorkShopInfoForm.aspx",
                title: "新增车间", width: 408, height: 255,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "new" };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    grid.reload();
                }
            });
        }
        function ondoubleclick() { edit(); }
        function edit() {
            var rows = grid.getSelected();
            if (rows) {
                mini.open({
                    url: "BasicDataManage/WorkShopInfoForm.aspx",
                    title: "编辑车间", width: 408, height: 255,
                    onload: function () {
                        var iframe = this.getIFrameEl();
                        var data = { action: "edit", WSID: rows.WSID };
                        iframe.contentWindow.SetData(data);
                    },
                    ondestroy: function (action) {
                        grid.reload();
                    }
                });
            }
            else {
                mini.alert("请选中一条您需要编辑的记录!");
            }
        }
        function freeze() {
            var rows = grid.getSelected();
            if (rows) {
                if (rows.RecStatus == true) {
                    mini.confirm("您确定禁用:" + rows.WSName + "？", "确定？",
                    function (action) {
                        if (action == "ok") {
                            $.ajax({
                                url: "../service/PublicHandler.ashx?action=Freeze&table=UT_WorkShop&field=WSID&value=" + rows.WSID,
                                success: function (text) {
                                    grid.reload();
                                },
                                error: function () {
                                }
                            });
                        } else {
                            return false;
                        }
                    });
                }
                else {
                    mini.alert(rows.WSName + " 当前状态已经是：已禁用!");
                }

            } else {
                mini.alert("请选中一条您需要禁用的记录!");
            }
        }

        function unfrozen() {
            var rows = grid.getSelected();
            if (rows) {
                if (rows.RecStatus == false) {
                    mini.confirm("您确定启用:" + rows.WSName + "？", "确定？",
                    function (action) {
                        if (action == "ok") {
                            $.ajax({
                                url: "../service/PublicHandler.ashx?action=Unfrozen&table=UT_WorkShop&field=WSID&value=" + rows.WSID,
                                success: function (text) {
                                    grid.reload();
                                },
                                error: function () {
                                }
                            });
                        } else {
                            return false;
                        }
                    });
                }
                else {
                    mini.alert(rows.WSName + " 当前状态已经是：已启用!");
                }

            } else {
                mini.alert("请选中一条您需要启用的记录!");
            }
        }

        function onRecStatusRenderer(e) {
            if (e.value == "0") { return "<span style=\"color: Red;font-weight:bold;\">已禁用</span>"; }
            else if (e.value == "1") { return "<span style=\"color: Green;font-weight:bold;\">已启用</span>"; }
            else { return ""; }
        }
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }
        function close() {
            CloseWindow("close");
        }
    </script>
</body>
</html>
